package com.ylz.sjzx.sio.room.service.impl;

import com.ylz.sjzx.sio.common.mid.cache.redis.JedisTemplate;
import com.ylz.sjzx.sio.common.core.constant.Const;
import com.ylz.sjzx.sio.sdk.client.service.UserSessionService;
import com.ylz.sjzx.sio.sdk.client.session.UserSession;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 分布式session
 *
 * @author sqy
 * @version 1.0
 * @date 2021/3/24
 */
@Slf4j
@Service(value = "userL1SessionServiceImpl")
public class UserL1SessionServiceImpl implements UserSessionService {

    @Override
    public void save(UserSession session) {
        Map<String, String> result = new HashMap();
        //userId
        result.put("userId", session.getUserId());
        JedisTemplate.me().hmset(Const.DISTRIBUTED_SESSION + session.getUserId(), result);
    }

    @Override
    public UserSession getByUserId(String uid) {
        return null;
    }

    @Override
    public UserSession getOrAddByUserId(String uid) {
        return null;
    }
}
